
package Sgdb::Preferences ;
use Sgdb::Utils qw(:DEFAULT
                   bind_search_mechanism
                   bind_font_resize
                   please_close_me
                   recursive_mkdir
                   ) ;

# pragmas for all
use warnings ;
use strict ;
use integer ;
use bytes ;

my %prefered ;
# our @prefered_file ; TODO: handle this virtual file and save at END{ .. }
my $font_dialog ;
# our $reconfig_force ;
our $bind_keys_text = '' ;
my %ex_pref_files ;

init () ;

sub init {
    init_defaults() ;
    init_from_file() ;

    foreach my $pref ( join ( '-', 'default-initial', ($ENV{DISPLAY} || 'local') =~ /^([\d\.]+|\w+)/, 'args' ),
                       join ( '-', 'default-initial', ($ENV{HOSTTYPE}|| 'local'), 'args'),
                       'default-initial-args' ) {

      unshift @ARGV, split ' ', pref $pref ;
    }
    hook_add ( 'everything-up-and-running' =>
               sub {
                   bind_font_resize $mainwindow ;
                   bindkey 'C-plus'  => '', ' (C-+) Increase Font Size' ;
                   bindkey 'C-minus' => '', ' (C--) Decrease Font Size' ;
                   bindkey 'C-question' => [\&floating_window, 'keys' ], ' (C-?) Display keyboard shortcut' ;
               },
               'display-shortcut-keys' =>  [\&floating_window, 'keys' ],
             ) ;
    1 ;
}

sub new {

    my $self = shift or die 'whoami' ;
    my $topf = shift or die 'topf needed' ;
    my $focus= shift ;

    my $text = $topf -> Scrolled ( 'ROText',
                                   pref 'preferences-text'
                                   ) ;

    foreach my $key ( sort keys %prefered ) {

        my  @val = split ' ', ($prefered { $key } || '') ;
        if (@val & 1 ) {

            $text -> insert( 'end',
                             "\n" => 'regtext',
                             $key . (' ' x ( 31 - length $key)) => 'regtext',
                              '=' => 'regtext',
                             ) ;
        }
        else {

            $text -> tagConfigure( $key => tag_configure_filter( @val) ) ;
            $text -> insert ( 'end',
                              "\n" => 'regtext',
                              $key . (' ' x ( 31 - length $key)) => $key,
                              '=' => 'regtext',
                              ) ;
        }
        my $e = $text -> Entry ( -width => 45,
                                 -background => 'white',
                                 -foreground => 'black',
                                 ) ;

        $e -> insert ('end' => join ' ', @val ) ;

        $text -> windowCreate ( 'end',
                                -window => $e,
                                -stretch => 1,
                                -padx => 5,
                                ) ;
        if ( $focus and $focus eq $key ) {

            $e -> focus() ;
            $text -> see ( 'end' ) ;
        }
    }
    # end foreach key

    $text -> tagRaise('sel' ) ;

    $text -> tagConfigure( 'e-search',
                           -background  => 'red2',
                           -foreground  => 'white',
                           -relief      => 'raised',
                           -borderwidth => 3
                         ) ;
    # Algo: should not use default pref() for this matter, guess why..

    bind_search_mechanism $text ;

    my $m = $text -> menu() ;
    $m -> configure( -postcommand => [\&popup_menu_for_prefset, $m, $text]) ;

    my $bg = $text -> cget ( '-background' ) ;
    $topf -> configure ( -background => $bg ) ;

    my $f = $topf -> Frame( -background => $bg ,
                            ) -> pack ( -fill => 'x',
                                        -pady => 0,
                                        ) ;
    my @button_pref = ( -width => 10, pref 'preferred-button' ) ;

    $f -> Button ( -text => 'O.K./Save',
                   -command => [\&save_my_preferences, $text],
                   @button_pref,
                   ) -> pack ( -side => 'left',
                               -anchor => 'w',
                               -padx => 5,
                               -pady => 0,
                               ) ;

    $f -> Button ( -text => 'Cancel/Close',
                   -command => [\&please_close_me, $f],
                   @button_pref,
                   ) -> pack ( -side => 'left',
                               -anchor => 'w',
                               -padx => 5,
                               -pady => 0,
                               ) ;

    $text -> pack( qw/-fill both -expand 1/) ;
}

sub ex_dotsgdbfile {
    my $name = shift ;
    if (my $preffile = args 'preffile' ) {
        return $preffile ;      # user preference file, no defaults
    }
    my $sgdb = $ENV{HOME} . '/.sgdb' ;

    use File::Basename ;
    my $dir = dirname( $name ) ;
    recursive_mkdir "$sgdb/$dir" ;

    "$sgdb/$name" ;
}

sub ex_bindkey {

    my $widget = ref $_[0] ? shift : $mainwindow ;
    my ($key, $action, $legend ) = @_ ;

    $bind_keys_text .= "\n$key:\t$legend" if $legend ;

    $key =~ s/M\-/Meta\-/ ;
    $key =~ s/C\-/Control\-/ ;
    $key =~ s/S\-/Shift\-/ ;
    $key = "<$key>" unless $key =~ /^<.*>$/ ;

    $widget -> bind ( $key => $action ) if $action; # allow empty legend
}

my $floating_window ;
my $floating_window_caller ;
sub floating_window {
    return telthemloud "internal error: can't find Sgdb::Helper" unless require Sgdb::Helper ;
    my ($topf, $type) = @_ ;
    # ($topf, $type) = ($type, $topf) unless ref $topf ;
    ($type, $topf) = ($topf,$mainwindow) unless ref $topf ;
    $floating_window_caller = $topf ;
    $topf = $topf -> toplevel ;
    my $w = $floating_window ||= eval {
        my $_w = $topf -> Toplevel ( qw/ -borderwidth 1 -background black -relief ridge / ) ;
        $_w -> overrideredirect(1);
        $_w -> withdraw() ;
        $_w -> bind ( '<Escape>',   \&floating_window_close) ;
        $_w -> bind ( '<FocusOut>', \&floating_window_close) ;
        bind_font_resize $_w ;
    };
    for my $c ( $w -> children()) {
        eval { $c -> packForget() }
    }
    Sgdb::Helper -> fill_keys ($w, $type ) ;
    my ($xx, $yy ) = ($topf -> rootx() + 28, $topf -> rooty() + 40);
    # telme "+$xx+$yy" ;
    $w->geometry("+$xx+$yy");
    $w->deiconify;
    $w->raise;
    # $w->{_CT_popped} = 1 ;
    $w -> focus() ;
}

sub floating_window_close {
    # eval { $floating_window -> destroy } ;
    # $floating_window = undef ;
    eval { $floating_window -> withdraw()  } ;
    eval { $floating_window_caller -> focus } ;
}

sub ex_pref_reconfigure {

    my $pref = 'default-frame' ;

    foreach my $w ( @_ ) {

        if    ( ! ref $w ) {

            $pref = $w ;
        }
        else {

            eval { $w -> { 'sgdb-pref' } = $pref } ;
            telme $@ if $@ ;
        }
    }
}

sub reconfigure_all {

    # this is a recursive function that checks for Tk object before calling

    my $root = shift ;

    eval {

        # Note: I assumes Tk widgets to be blessed hash. therefore, must eval!

        my $class = $root -> class () or return ;

        if    (exists $root -> { 'sgdb-pref' } ) {

            my $pref= $root -> { 'sgdb-pref' } ;

            $root -> configure ( ex_pref ( $pref )  ) ;

            if ( $class eq 'Text' ) {

                foreach my $tag ( $root -> tagNames() ) {

                    my @tagpref = ex_pref ( "$pref-$tag-tag" ) ;

                    $root -> tagConfigure( $tag, @tagpref ) if @tagpref ;
                }
            }
        }
    } ;
    telme $@ if $@ ;

    foreach my $w ( $root -> children ) {

        reconfigure_all ( $w ) if substr ( ref $w, 0, 3) eq 'Tk:' ;
    }
}

my %sgdb_fonts ; # old_name => new_name

sub ex_change_font_size {
    # todo:
    #  replace each font $f with $sgdb_fonts{"sgdb$f"} font alias.
    #  increase each %sgdb font size
    my %fonts = map {($_->as_string(), undef )} values %sgdb_fonts ;
    use Tk::Font ;
    my ($up, @w) = @_ ;
    ($up, $w[0]) = ($w[0], $up) if ref $up ;
    @w = $mainwindow unless @w ;
    while (@w) {
        my $w = shift @w ;
        next unless ref $w and ref $w ;
        eval { push @w, $w -> children };
        my ($f) = grep {'Tk::Font' eq ref $_ } map {'ARRAY' eq ref $_ ? @$_ : $_ } eval {  $w -> configure('-font') } ;
        $DB::single = 1;
        my $n = eval {$f->as_string} ;
        next unless $n and not exists $fonts {$n} ;
        $w -> configure( -font => $sgdb_fonts{$n} ||= eval {
            my $clone = $f -> Clone() ;
            $fonts{$clone->as_string} = undef ;
            $clone
        }) ;
    }

    return unless $up ;
    for my $v (values %sgdb_fonts) {
        my $s = $v -> configure('-size') ;
        $v -> configure( -size => $s > 0 ? $s + $up : $s - $up ) ;
    }
}

sub save_my_preferences {

    my $t = shift ;
    my %pf = %prefered ;
    my %df ;

    if ( open FILE, get_preferenaces_file() ) {

        while (<FILE>) {
            /^\s*\#/ and next ;
            $df{ $1 } = $2 if /^\s*([\w\-]+)\s*\=\s*(.*?)\s*$/o ;
        }
        close FILE ;
    }

    open FILE, '>' . get_preferenaces_file() or
        return
            telthemloud "can't open ", get_preferenaces_file(), ": $!\n" ;

    foreach my $ei ( $t -> windowNames() ) {

        my $key = $t -> get ("$ei linestart" => "$ei -1 c" ) ;
        $key =~ y/ //d ;
        $key or next ;
        my $win = $t -> windowCget ( $ei, '-window') ;
        $win || telthemloud ("Internal Error: can't save $key") || next ;
        my $val = $win -> get() ;
        $val =~ s/^\s+// ; $val =~ s/\s+$// ;

        if ( ( exists  $df{ $key } ) or
             ( $val || $pf{ $key }   and
               $val ne $pf{ $key } || ''  )
             ) {

                 print FILE
                     $key,
                     (' ' x (30 - length $key)),
                     '= ',
                     $val,
                     "\n" ;

                 $prefered{ $key } = $val ;
             }
    }

    close FILE ;

    please_close_me( $t ) ;
    # Algo : don't want to waste time for reconfiguring this one

    reconfigure_all ( $mainwindow ) ;
    hook_run 'reconfigure-all' ;
}

sub popup_menu_for_prefset {

    my ($m, $t) = @_ ;
    $m -> delete (0 => 'end') ;

    my $c = $t -> index ( 'current' ) ;
    my $w = $t -> get ("$c linestart" => "$c lineend -2 c") ;
    my $e = $t -> windowCget ( "$c lineend -1 c", '-window' ) ;

    $w =~ s/ //g ;
    my ($type) = $w =~ /(\w+)$/ ;

    my %atr = ( 'menu'   => q/ background foreground font relief activebackground activeforeground selectcolor /,
                'text'   => q/ background foreground font        wrap /,
                'tag'    => q/ background foreground font relief wrap /,
                'frame'  => q/ background foreground      relief /,
                'entry'  => q/ background foreground font relief /,
                'button' => q/ background foreground font relief activebackground activeforeground /,
                'balloon'=> q/ background foreground font        state /,
                'listbox'=> q/ background foreground font        /,
                'label'  => q/ background foreground font        /,
                'args'   => q/ background foreground font        /,
              ) ;

    if ( exists $atr{ $type } ) {
        popup_menu_add_options( $m, $e, $w, split ' ', $atr{ $type } ) ;
    }
    else {
        $e -> bell;
        telthem "Expecting numeric or string value" ;
        $e -> focus ;
    }
}

sub popup_menu_add_options {

    my ($m, $e, $w) = (shift, shift, shift) ;

    my %opt = ('wrap'   => [ qw/ char word none/ ],
               'relief' => [ qw/ raised sunken flat ridge solid groove/ ],
               'state'  => [ qw/ both status balloon none/ ],
               ) ;

    foreach my $atr (@_) {

        if    ( exists $opt{ $atr } ) {

            my $sm = $m -> Menu ( -tearoff => 0,
                                  pref 'pop-menu'
                                  ) ;

            foreach my $opt ( @{ $opt{ $atr } } ) {
                $sm -> add ('command',
                            -label => $opt,
                            -command => [\&change_attr, $e, $atr, $opt]
                            ) ;
            }

            $m -> add ( 'cascade',
                        -label => $atr,
                        -menu => $sm
                        ) ;
        }
        elsif ( $atr eq 'background'       or
                $atr eq 'foreground'       or
                $atr eq 'activebackground' or
                $atr eq 'activeforeground' or
                $atr eq 'selectcolor'
                ) {
            $m -> add ( 'command',
                        -label => "$atr..",
                        -command => sub {
                            my $color = $e -> chooseColor() or return ;
                            change_attr( $e, $atr, $color) ;
                        }
                        ) ;
        }
        elsif ( $atr eq 'font' ) {
            $m -> add ( 'command',
                        -label => "$atr..",
                        -command => sub {
                            return telthemloud "cannot locate Tk::Font module" unless
                              require Tk::Font ;
                            return telthemloud "cannot locate Tk::FontDialog module"  unless
                              require Sgdb::Tk::FontDialog ;
                            $font_dialog ||= $mainwindow -> FontDialog (-font => 'actual') ;
                            my $font = $font_dialog -> Show or return ;
                            $font = $font->Pattern() ;
                            $font =~ y/ /~/ ;
                            change_attr( $e, $atr, $font ) ;
                        }
                        ) ;
        }
    }
}

sub change_attr {

    my ($e, $a, $b) = @_ ;

    my $str = $e -> get() ;

    $a = "\Q$a" ;

    if ( $str =~ s/\-?\b$a\s+\S+/\-$a $b/g ) {
        $e -> delete (0 => 'end') ;
        $e -> insert (0, $str) ;
    }
    else {
        $e -> insert ('end', " -$a $b") ;
    }
}

sub tag_configure_filter {


    my @val ;
    my %opt = @_ ;

    foreach my $val (qw( background
                         foreground
                         relief
                         borderwidth
                         underline
                         font
                         overstrike
                      )) {      # perl 5.14 wants double quotes ...

        if (exists $opt{ '-'.$val } ) {
            push @val, '-'.$val, $opt{ '-'.$val } ;
        }
        elsif (exists $opt{ $val } ) {
            push @val, '-'.$val, $opt{ $val }  ;
        }
    }
                     @val ;
                 }

sub ex_pref {
    # Algo: a call for pref( 'this-is-a-key' ) will :
    # 1. if not exists, create the entry 'this-is-a-key' in %prefered
    # 2. search for the keys: 'this-is-a-key', 'this-is-a', 'this-is' and 'this'
    #    until first found (if any). this way, 'this-is' can become a default for
    #    a branch of keys.
    # 3. for some key words it will return an array, for others it will return scalar.
    #    (it was done this way to force 'proper' key writing for latter use.)
    # 4. CHANGED 2/27/01: let type be the last word in key chain

    my $key = shift or die "I need a key" ;
    my ($type) = $key =~ /(\w+)$/ ;

    my $file = shift ;
    if ($file and not
        $ex_pref_files{$file} ) {
        init_from_file($file) ;
        $ex_pref_files{$file} = 1 ;
    }

#     my $pref = exists $prefered{ $key } ? $prefered{ $key } : $prefered{ $key } = undef ;
#  is it a perl bug ?

    my $pref ;
    if   ( exists $prefered{ $key } ) { $pref = $prefered{ $key } }
    else                              { $pref = $prefered{ $key } = undef }
    # Algo: even if not exists, create the entry for later use

    while ( !$pref and $key =~ s/-\w+$// ) {

        $pref = $prefered{  $key        } if exists $prefered{  $key        } ;
        $pref = $prefered{ "$key-$type" } if exists $prefered{ "$key-$type" } ;
    }
    $pref ||= '' ;

    foreach my $tkw (qw ( menu
                          text
                          tag
                          frame
                          entry
                          button
                          balloon
                          listbox
                          label
                          tablematrix
                          ) ) {
        # expecting hash argument list

        return
            map {y/~/ /; $_}
            split (' ', $prefered{ "default-$type"}),
            split (' ', $pref)
                if $type eq $tkw ;
        # Prelon: "' '" got a special meaning for split. lookup the Camel.
    }

    return $pref || '' ;
}

sub ex_pref_set {
    my ($key, $val, $file) = map { ref() ? $$_ : $_ }  @_ ;
    $key =~ s/^\s+// ;
    $key =~ s/\s+$// ;
    # $key =~ s/^\s*([\w\-]+)/$1/ ;

    $prefered{ $key } = $val ;

    $file = get_preferenaces_file($file) ;
    my $F = '' ;

    local $/ = undef ;
    open FILE,   $file and $F = <FILE> ;
    open FILE, ">$file" or return telthemloud "can't write to $file: $!\n" ;
    $F =~ s/^\s*$key\s*\=.*//gm ;
    $F =~ s/\s+$//s ;
    print FILE $F, "\n$key = $val\n" ;
    # foreach my $line ( @file ) {
    #     next unless    $line =~ /^\s*([\w\-]+)\s*\=/ ;
    #     $1 eq $key and $line = '' ;
    # }

    # print FILE @file ;
    # print FILE "$key = $val\n" if $val ;
    close FILE ;

    $val ;
}

sub set_prefs_from_lines {
    for (@_) {
        /^\s*\#/   and next ;
        /^\s*([\w\-\.]+)\s*\=\s*(.*?)\s*$/o and $prefered{ $1 } = $2 and next ;
#         /^\s*(<\S+?>)(.*)/                and $bindings{ $1 } = $2 and next ;
    }
}

sub init_defaults {

    set_prefs_from_lines (split /^/, the_defaults() ) ;
#    set_prefs_from_lines (<DATA>) ;
#    close DATA or telme "can't close DATA: $!" ;
}

sub init_from_file {

    my  $file = get_preferenaces_file(@_);

    return
      unless $file and -f $file ;

    open F, $file or return telthem "cannot open $file: $!" ;
    set_prefs_from_lines (<F>) ;
    close F ;
}

sub get_preferenaces_file {

    if (my $preffile = args 'preffile' ) {
        return $preffile ;      # user preference file, no defaults
    }
    $_[0] ? ex_dotsgdbfile($_[0]) : $ENV{HOME} . '/.sgdbpref' ;
}


####   __DATA__  # let's make it win32 compatible
sub the_defaults { <<'DEFAULT_PREFERENCES' ;

# array (words) values : starts with a key word

# default-menu                 = -activebackground grey90
default-menu                 = -background grey90 -foreground black
default-text                 = -background grey95 -foreground black -wrap none
default-tag                  = -relief flat -borderwidth 0
default-frame                = -background grey95 -foreground black
default-entry                = -background white
default-button               = -background grey90 -activebackground grey85 -cursor arrow
default-balloon              =
default-listbox              =
default-label                =
default-initial-args         = -foreground black
default-e-search-tag         = -background blue4 -foreground white
default-tablematrix          = -scrollbars ose -anchor w -relief sunken -fg black

status-bar-label             = -relief raised -borderwidth 2 -background grey85 -justify left

source-fileheader-tag        = -relief sunken -borderwidth 2 -background grey90 -lmargin1 5
source-fileheader-warning-tag = -relief sunken -borderwidth 2 -background grey90 -lmargin1 5 -foreground red
source-linenumber-tag        = -relief sunken -borderwidth 1 -background grey90 -foreground grey50
source-face-comments-tag     = -foreground gold4
source-face-instructs-tag    = -foreground red4
source-face-quotations-tag   = -foreground green4
source-face-keywords-tag     = -foreground BlueViolet
source-face-knowntypes-tag   = -foreground MediumBlue
source-asm-addr-tag          = -foreground blue          -background grey90        -relief sunken -borderwidth 1
source-asm-offset-tag        = -foreground blue          -background grey90        -relief sunken -borderwidth 1 -elide 1
source-asm-comm-tag          = -foreground tomato3       -background #ffffefded5c2 -relief sunken -borderwidth 1
source-asm-osrc-tag          = -foreground #54bc84b0ffff -background #feffeeded3c2 -relief sunken -borderwidth 1
source-asm-ocomm-tag         = -foreground tomato2       -background #feffeeded3c2 -relief sunken -borderwidth 1
source-cur-line-tag          = -background Yellow
source-highlight-patches-tag = -background #ddf3fa9fffff
source-cur-address-tag       = -background GreenYellow
source-loc-breakpoint-tag    = -background red4
source-loc-dis-breakpoint-tag = -background pink3
source-loc-tracepoint-tag    = -background red2
source-loc-dis-tracepoint-tag = -background pink1
source-loc-tstatus-mis-tag   = -background pink1
source-branchp-mis-tag       = -background pink1
source-branchp-con-tag       = -background #c20cdeb7ffff
source-branchp-hit-tag       = -background #9709ffff0000
source-loc-tstatus-hit-tag   = -background #c20cdeb7ffff
source-cvs-error-tag         = -foreground red4 -background white
source-cvs-1-tag             = -foreground black -background #ffffb851c75e
source-cvs-2-tag             = -foreground black -background #ffffffffabc6
source-cvs-3-tag             = -foreground black -background #ad91f1a9ba1c
source-cvs-4-tag             = -foreground black -background #b2f1e51effff
source-cvs-5-tag             = -foreground black -background #b2f1bdb1da5d
source-patch-1-tag           = -foreground blue4 -background #d01f9cb7a5a9
source-patch-2-tag           = -foreground blue4 -background #e474e49a9964
source-patch-3-tag           = -foreground blue4 -background #86babba59077
source-patch-4-tag           = -foreground blue4 -background #b2f1e51effff
source-patch-5-tag           = -foreground blue4 -background #b2f1bdb1da5d
source-patch-temp-tag        = -foreground red4  -background #ddf3fa9fffff

command-prompt-text          = -background white -foreground black -wrap none
command-prompt-command-entry = -background white -foreground black
command-prompt-prompt-tag    = -foreground tomato3
command-prompt-command-tag   = -foreground blue4
command-prompt-result-tag    = -foreground black
command-prompt-error-tag     = -foreground red
command-prompt-clicked-tag   = -foreground green4 -underline 1
command-prompt-completions-tag = -foreground blue4 -background grey95 -relief sunken -borderwidth 1
command-prompt-switch-tag    = -foreground white -background red4
command-prompt-grab-focus    = 1

service-pane-button          = -padx 3 -pady 3 -background #d686f8c7ffff -foreground #273440488b84 -activebackground #e516f7cdd953
service-pane-entry           = -background white
service-pane-title-tag       = -foreground #7a1c53f70000
service-pane-glink-tag       = -foreground blue4 -underline 1
service-pane-glinked-tag     = -foreground red4  -underline 1
service-pane-symm-loc-tag    = -foreground blue4
service-pane-text            =
service-pane-symm-button     = -padx 0 -pady 0 -relief groove -highlightthickness 1 -highlightbackground gold
service-pane-symm-colors     = green green2 yellow yellow2
service-pane-rms-button      = -padx 0 -pady 0 -foreground blue4 -background #eec9eed8d1b4

file-edit-button             =
file-edit-pane-text          =

set-actions-button           =
set-actions-actions-text     = -background WhiteSmoke -foreground black -relief sunken -borderwidth 2
set-actions-actions-tag      = -foreground black
set-actions-clues-tag        = -foreground grey50
set-actions-hlight-tag       = -background pink
set-actions-btext-tag        = -foreground black
set-actions-gtext-tag        = -foreground grey50
set-actions-rtext-tag        = -foreground red4
set-actions-glink-tag        = -foreground blue4 -underline 1
set-actions-llink-tag        = -foreground blue4 -underline 1

registers-win-text           =
registers-win-name-tag       = -borderwidth 1
registers-win-changed-tag    = -background oldlace -relief sunken -borderwidth 1 -foreground #d6c700000000
registers-win-same-tag       = -background oldlace -relief sunken -borderwidth 1 -foreground grey30

tracepoints-win-trace-tag    = -foreground blue4
tracepoints-win-actions-tag  = -relief sunken -borderwidth 1 -background oldlace
tracepoints-win-header-tag   = -relief raised -borderwidth 1 -foreground gold4
tracepoints-win-invalid-msg-tag = -foreground red4 -background white

inlines-text                 = -background grey30 -foreground white
inlines-command-entry        = -relief sunken -borderwidth 1 -background grey75 -foreground black
inlines-command-tag          = -foreground white
inlines-prompt-tag           = -borderwidth 3
inlines-gdb-cmd-tag          = -foreground yellow

display-watch-expr-tag       = -foreground black
display-watch-expr-cmd-tag   = -foreground blue4
display-watch-value-tag      = -background oldlace -relief sunken -borderwidth 1
display-watch-no-frame-tag   = -background white -foreground red4  -borderwidth 1 -relief raised
display-watch-frame-tag      = -background white -foreground blue4 -borderwidth 1 -relief raised

symbols-lookup-title-tag     = -foreground blue4 -relief raised -borderwidth 1
symbols-lookup-lookup-tag    = -foreground blue4 -relief sunken -borderwidth 1 -background oldlace

usage-lookup-title-tag       = -foreground black -relief raised -borderwidth 1
usage-lookup-lookup-tag      = -foreground blue4 -underline 1
usage-lookup-code-tag        = -foreground grey30

etags-lookup-title-tag       = -foreground red4 -background oldlace -relief raised -borderwidth 1
etags-lookup-lookup-tag      = -foreground blue4 -underline 1

profiler-pane-frame          = -relief sunken -borderwidth 2
profiler-pane-index-tag      = -relief sunken -borderwidth 1 -background oldlace -foreground grey50
profiler-pane-addr-tag       = -foreground blue4
profiler-pane-calls-tag      = -foreground black
profiler-pane-self-tag       = -foreground black
profiler-pane-total-tag      = -foreground black
profiler-pane-pself-tag      = -foreground red4
profiler-pane-ptotal-tag     = -foreground red4
profiler-pane-func-tag       = -foreground blue4
profiler-pane-errmsg-tag     = -relief sunken -borderwidth 1 -background oldlace -foreground red4
profiler-pane-link-tag       = -foreground blue4 -underline 1
profiler-pane-button         = -padx 3 -pady 1 -background #d686f8c7ffff -foreground #273440488b84 -activebackground #e516f7cdd953
profiler-pane-tablematrix    = -scrollbars ose -anchor w -padx 2 -ipadx 5 -pady 1 -width 30 -relief sunken -fg black
ev-trace-pane-frame          = -relief sunken -borderwidth 2

function-call-button         = -padx 1 -pady 1 -background #d686f8c7ffff -foreground #273440488b84 -activebackground #e516f7cdd953
function-call-label          =
function-call-vartype-label  = 
function-call-entry          = -background white -relief sunken -borderwidth 1
function-call-type-tag       = 
function-call-results-text   = 

status-pane-header-tag       = -borderwidth 3 -background oldlace
status-pane-link-tag         = -underline 1 -foreground blue
status-pane-linked-tag       = -underline 1 -foreground red4
status-pane-addr-tag         = -borderwidth 3
status-pane-zero-tag         = -relief sunken -borderwidth 1 -background white -foreground grey80
status-pane-blank-tag        = -borderwidth 3
status-pane-value-tag        = -relief sunken -borderwidth 1 -foreground black

help-mode-balloon            = -state none -balloonposition mouse -background #f603fffffb06 -initwait 250

message-win-text             = -wrap word

check-fix-win-frame          = -background #dceddceddced
choose-fix-win-listbox       = -background #ae00c311b03c

major-minor-label            = -background green -foreground black

main-window-frame            = -background #dceddceddced

control-panel-buttons-list   = source_browser step stepi next load continue up down cleanup
control-panel-buttons-tracepoints-list   = tstart tstop tstart_all tstop_all tfind tfind_prev tfind_line tfind_none tfind_prev tfind_this_pc tstatus swuch swuchChat-16

disassemble-while-stepping   = 1
max-retries-queued-inlines   = 5

last-symbol-filename         =
last-gdb-exec                = auto  (ppc/m68)
last-scratch-directory       = ~/tmp/.sgdb_scratch
last-geometry-save-at-exit   = 1
last-target-type             = symmetrix
last-init-file               = ~/.sgdbrc
last-swuch-init-file         = ~/.swuchrc
last-remote-hosts-file       = ~/.sgdbhosts

swuch-symm-button            = -padx 0 -pady 0 -relief groove -highlightthickness 1 -highlightbackground yellow4 -bd 2
swuch-symm-label             = -padx 0 -pady 0 -relief flat
swuch-photo-label            = -padx 10 -pady 30 -relief raised -borderwidth 7 -background black
swuch-text-swuchlog-tag      = -background grey25 -relief ridge -borderwidth 3
swuch-text-clicked-tag       = -background grey25 -underline 1
swuch-inlines-text           = -background grey10 -foreground white -scrollbars e  -insertbackground yellow
swuch-message-text           = -scrollbars e
swuch-script-button          = -padx 2 -pady 2 -relief groove -highlightthickness 1 -highlightbackground yellow4
swuch-script-completions-tag = -foreground blue4 -background grey75 -relief sunken -borderwidth 1
swuch-script-cur-mark-tag    = -background green
swuch-script-api-mark-tag    = -background yellow
swuch-script-error-tag       = -background pink1
swuch-script-scriptname-tag  = -underline 1 -foreground blue
swuch-script-header-tag      = -foreground red4
swuch-script-comment-exec-tag = -foreground pink3
swuch-script-comment-tag     = -foreground red3
swuch-completion-list-label    = -background oldlace   -foreground blue
swuch-completion-doc-label     = -background oldlace   -foreground blue
swuch-completion-paramA-label  = -background oldlace   -foreground black
swuch-completion-paramB-label  = -background white     -foreground red4 -padx 3
swuch-completion-paramC-label  = -background oldlace   -foreground black
swuch-completion-inline-label  = -background AliceBlue -foreground black
swuch-completion-hex-label     = -background AliceBlue -foreground red4

swuch-chat-self-tag          = -foreground grey50
swuch-chat-other-tag         = -foreground black
swuch-chat-error-tag         = -foreground red4
swuch-chat-message-tag       = -foreground blue4 -background grey90

swuch-ibrowser-fullkey-tag   = -foreground red4
swuch-ibrowser-partkey-tag   = -foreground blue4
swuch-ibrowser-error-tag     = -foreground red4 -background white -lmargin1 4 -relief raised -borderwidth 3
swuch-ibrowser-button        = -pady 1 -padx 1 -relief groove  -highlightthickness 1 -highlightbackground yellow4 -background #d5c1fffffd35 -activebackground #b0e4fc32ffff

swuch-ibrowser-name-tag      = -foreground black -relief raised -borderwidth 2 -spacing1 4 -spacing3 4
swuch-ibrowser-code-tag      = -foreground blue4 -relief sunken -borderwidth 2 -lmargin1 2 -spacing1 4 -spacing3 4
swuch-ibrowser-desc-tag      = -foreground black -background white -lmargin1 4
swuch-ibrowser-param-tag     = -foreground blue4 -lmargin1 2
swuch-ibrowser-param-list    = red3 gold4 green #697869786978 #645c9592edd2 #55526b842f33 #eed86a49a787 #eed89ac50000 #7a7f8b848b84 #c9b90000ffff
swuch-ibrowser-keys-text     = -scrollbars osoe
swuch-ibrowser-value-text    = -scrollbars osoe -background oldlace
swuch-ibrowser-label         = -justify left -takefocus 0 -relief groove -pady 0 -borderwidth 1

swuch-hotkeys-complete       = 1
swuch-autosave-inline-history = 1
swuch-urgent-files-text      = -background grey80 -foreground red3

passive-prof-label           = -foreground red4 -relief ridge -borderwidth 1
passive-prof-button          = -foreground blue -background grey90 -padx 1 -pady 1 -highlightthickness 1 -highlightbackground yellow4
passive-prof-entry           = -background white -relief sunken -borderwidth 1 -foreground blue

dump-patches-fix-name-tag    = -foreground red4 -relief raised -borderwidth 3
dump-patches-unchanged-tag   = -foreground grey30
dump-patches-changed-tag     = -foreground black
dump-patches-name-tag        = -foreground blue4
dump-patches-head-tag        = -foreground blue4 -relief sunken -borderwidth 2

error-lookup-message-tag     = -foreground black -background white  -relief ridge  -borderwidth 2 -lmargin1 4 -spacing1 2 spacing3 4
error-lookup-loud-tag        = -foreground red4  -relief raised -borderwidth 2
error-lookup-error-tag       = -foreground blue4 -underline 1
error-lookup-sevr-tag        = -foreground red4  -background grey90 -relief sunken -borderwidth 4 -lmargin1 4 -spacing1 2
error-lookup-desc-tag        = -foreground black -background grey90 -relief sunken -borderwidth 4 -lmargin1 4
error-lookup-internal-tag    = -foreground black -background yellow -relief sunken -borderwidth 4 -lmargin1 4
error-browser-frame          = -background #f0e4f8edffff -borderwidth 2
error-browser-label          = -background #f0e4f8edffff
error-browser-menu           = -background #f0e4f8edffff
error-browser-button         = -background #f4fcd776be1c -activebackground green2
error-browser-dir-tag        = -borderwidth 1 -relief sunken -foreground blue4
error-browser-error-tag      = -borderwidth 1 -relief sunken -foreground red4
error-browser-timer-tag      = -borderwidth 1 -relief sunken
error-browser-sr-tag         = -borderwidth 1 -relief sunken
error-browser-pc-tag         = -borderwidth 1 -relief sunken
error-browser-rem-tag        = -borderwidth 1 -relief sunken -foreground black -justify left

symmlink-pane-button         = -padx 1 -pady 1 -relief groove -highlightthickness 1 -highlightbackground yellow4 -bd 1 -width 6
symmlink-pane-label          = -foreground blue4 -justify left
symmlink-pane-frame          = -foreground blue4
symmlink-status-label        = -foreground blue4 -justify left -relief sunken -foreground grey20 -background oldlace -bd 4 -height 8
symmlink-unix-command-tag       = -foreground tomato3
symmlink-unix-shell-tag         = -foreground blue4
symmlink-unix-adihead-tag       = -foreground grey60
symmlink-unix-error-tag         = -foreground red4
symmlink-mainframe-command-tag  = -foreground tomato3 -relief sunken -borderwidth 1 -background #ffffefded5c2 -spacing1 2
symmlink-mainframe-report-tag   = -foreground blue4
symmlink-mainframe-error-tag    = -foreground red4
symmlink-symmetrix-finished-tag = -foreground green4
symmlink-symmetrix-ongoing-tag  = -foreground blue4
symmlink-symmetrix-command-tag  = -foreground blue4
symmlink-symmetrix-error-tag    = -foreground red4
symmlink-symmetrix-date-tag     = -foreground red4
symmlink-symmetrix-log-tag      = -foreground grey40
symmlink-symmlink-shell-tag     = -foreground blue2
symmlink-header-frame        = -background AliceBlue -padx 0 -pady 1
symmlink-header-label        = -background AliceBlue
symmlink-header-button       = -background #fffff5f1eed8 -padx 1 -pady 1 -activebackground WhiteSmoke
symmlink-header-menu-button  = -background #e977f574ffff -padx 1 -pady 1 -activebackground WhiteSmoke
symmlink-header-pop-menu     = -background #f0e4ffffffff -activebackground WhiteSmoke -activeforeground black
symmlink-right-frame         = -background AliceBlue    -borderwidth 1 -relief ridge 
symmlink-right-active-frame  = -background GreenYellow  -borderwidth 1 -relief raised
symmlink-right-error-frame   = -background red          -borderwidth 1 -relief raised
symmlink-right-label         = -background AliceBlue
symmlink-right-button        = -padx 2 -pady 0 -relief groove -highlightthickness 1 -highlightbackground gold -background #ffffe1c9e226 -width 12
symmlink-wizard-button       = -background #e977f574ffff -activebackground WhiteSmoke -padx 0 -pady 0 -relief groove -highlightthickness 1 -bd 2 -highlightbackground yellow4 -width 4
symmlink-wizard-label        = -background grey95 -foreground blue4 -justify left
symmlink-wizard-frame        = -background grey95 -foreground blue4 -borderwidth 1 -relief sunken
symmlink-idle-state-label    = -background AliceBlue -padx 2 -pady 2 -height 3 -relief sunken -foreground blue4
symmlink-active-state-label  = -background oldlace -padx 2 -pady 2 -height 3 -relief sunken -foreground blue4
symmlink-error-state-label   = -background pink3 -padx 2 -pady 2 -height 3 -relief sunken -foreground blue4
symmlink-browser-name-tag    = -foreground blue4 -underline 1 -spacing1 2 -lmargin1 4
symmlink-browser-header-tag  = -foreground red4 -spacing1 2 -lmargin1 4
symmlink-browser-mfweb-tag   = -foreground black -background grey90 -relief sunken -borderwidth 3
symmlink-browser-error-tag   = -foreground red4

symmwinlog-browser-button    = -background #e977f574ffff -padx 3 -pady 1 -activebackground WhiteSmoke  -activeforeground blue4 -width 50
file-completion-pop-menu     = -background #e6d8e6cefae0 -activebackground #f0e4f8edffff -foreground black
raise-pane-pop-menu          = -background #f0e4ffffffff -activebackground WhiteSmoke -activeforeground black

helper-key-tag               = -background #d709e9fbffff -foreground black
helper-value-tag             = -background #d709e9fbffff -foreground blue4
helper-title-tag             = -background #e709f9fbffff -foreground blue3 -borderwidth 3
helper-text                  = -background #d709e9fbffff
helper-filename-tag          = -foreground gold4 -borderwidth 2 -relief raised
helper-glink-tag             = -foreground blue4 -underline 1
helper-data-tag              = -background AliceBlue -relief sunken -borderwidth 1
helper-bttop-tag             = -foreground blue4 -underline 1 -justify right
helper-title-tag             = -foreground blue4

DEFAULT_PREFERENCES
}

'end'
